package org.springblade.modules.restaurant.wrapper;

import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.restaurant.entity.CustomerSituation;
import org.springblade.modules.restaurant.vo.CustomerSituationVO;
import org.springblade.modules.system.entity.User;
import org.springblade.modules.system.service.IUserService;

/**
 * @author harry
 * @公众号 Harry技术
 */
public class CustomerSituationWrapper extends BaseEntityWrapper<CustomerSituation, CustomerSituationVO> {
	private static final IUserService userService;

	static {
		userService = org.springblade.core.tool.utils.SpringUtil.getBean(IUserService.class);
	}

	public static CustomerSituationWrapper build() {
		return new CustomerSituationWrapper();
	}

	@Override
	public CustomerSituationVO entityVO(CustomerSituation entity) {
		CustomerSituationVO customerSituationVO = BeanUtil.copyProperties(entity, CustomerSituationVO.class);

		User user = userService.getById(customerSituationVO.getCreateUser());
		if (Func.isNotEmpty(user)) {
			customerSituationVO.setCreateUserName(user.getName());
		}
		User updateUser = userService.getById(customerSituationVO.getUpdateUser());
		if (Func.isNotEmpty(updateUser)) {
			customerSituationVO.setUpdateUserName(updateUser.getName());
		}
		return customerSituationVO;

	}
}
